package com.yeban.javase.day01.homework;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/9
 *
 * 银行账户类
 */
public class Account {

    private Long id;    // 账户号码
    private String password;    // 账户密码
    private String name;    // 真实姓名
    private String personId;    // 身份证号码
    private String email;   // 客户的电子邮箱
    private double balance; // 账户余额

    public Account() {
    }

    public Account(Long id, String password, String name, String personId, String email, double balance) {
        this.id = id;
        this.password = password;
        this.name = name;
        this.personId = personId;
        this.email = email;
        this.balance = balance;
    }

    public Account deposit(double money) {  // 存款方法
        if(money > 0) {
            balance += money;
        }
        return this;
    }

    public Account withdraw(double money) { // 取款方法
        if(money > balance) {
            System.out.println("余额不足！");
        }
        else if(money > 0 && balance <= money) {
            balance -= money;
        }
        return this;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
}
